//
//  GXMainTabBarViewController.m
//  GXKit_OC
//
//  Created by guangxiao on 2018/1/11.
//  Copyright © 2018年 guangxiao. All rights reserved.
//

#import "GXMainTabBarViewController.h"
#import "HomeViewController.h"
#import "MineViewController.h"
@interface GXMainTabBarViewController ()

@end

@implementation GXMainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self addChildViewControllers];
    
    [[UITabBar appearance] setTintColor: [UIColor greenColor]];
    
    [self.tabBar setBarTintColor:[UIColor colorWithRed:248 green:248 blue:248 alpha:0.5]];
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)addChildViewControllers{
    HomeViewController * homeVC = [[HomeViewController alloc] init];
    MineViewController * mineVC = [[MineViewController alloc] init];
    
    [self buildChildViewControllerWith:homeVC title:@"主页" imageName:@"home" selectedImageName:@"home_selected" tag:0];
    [self buildChildViewControllerWith:mineVC title:@"我的" imageName:@"mine" selectedImageName:@"mine_selected" tag:1];
    
}

-(void)buildChildViewControllerWith:(UIViewController *) childVC title: (NSString *) title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName tag:(NSInteger)tag{
    
    UITabBarItem * childTabItem = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:imageName] selectedImage:[UIImage imageNamed:selectedImageName]];
    
    childTabItem.tag = tag;
    
    childVC.tabBarItem = childTabItem;
    
    UINavigationController * naviVC = [[UINavigationController alloc] initWithRootViewController:childVC];
    
    [self addChildViewController:naviVC];
    
}

@end
